package com.lzx.article.controller.web;

import com.lzx.article.entity.SecondComments;
import com.lzx.article.service.SecondCommentsService;
import com.lzx.article.vo.NicknameVO;
import com.lzx.article.vo.OssVO;
import com.lzx.common.utils.R;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/article/secondComments/web")
public class WebSecondCommentsController {
    @Resource
    private SecondCommentsService secondCommentsService;

    //修改用户昵称(文章二级评论)
    @PutMapping("/updateNicknameToSecondComments")
    public String updateNicknameToSecondComments(@RequestBody NicknameVO nicknameVO) {
        return secondCommentsService.updateNicknameToSecondComments(nicknameVO);
    }

    //修改用户头像(文章二级评论)
    @PutMapping("/updateAvatarToSecondComments")
    public String updateAvatarToSecondComments(@RequestBody OssVO ossVO) {
        return secondCommentsService.updateAvatarToSecondComments(ossVO);
    }

    //根据文章id获取一级和二级评论
    @GetMapping("/getFirstAndSecondComments/{articleId}")
    public R getFirstAndSecondComments(@PathVariable Long articleId) {
        return secondCommentsService.getFirstAndSecondComments(articleId);
    }

    //保存二级回复
    @PostMapping("/publishSecondComments")
    public R publishSecondComments(@RequestBody SecondComments secondComments) {
        return secondCommentsService.publishSecondComments(secondComments);
    }
}
